import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import NotFound from '../pages/home/notFound/index';
import Empty from '../pages/home/notFound/empty';
// import classList from '../pages/classList/index';
// import login from '../pages/login/index';
import correctEditor from '../pages/correctEditor/index';
// import planList from '../pages/planList/index';
// import homeWork from '../pages/homeWork/index';
// import correctionRemark from '../pages/correctionRemark/index';
export type RouterType = RouteRecordRaw & { chname?: string; children?: any };
// history.pushState({},'') 回退
const homeRouter = [
  {
    name: 'home', // 首页
    path: '/',
    component: Empty
  },
  {
    name: 'login', // 登录
    path: '/login',
    component: () => import('../pages/login/index')
  },
  {
    name: 'classList', // 班级列表
    path: '/classList',
    component: () => import('../pages/classList/index')
  },
  {
    name: 'correctEditor', // 讲次列表
    path: '/correctEditor',
    component: correctEditor
  },
  {
    name: 'planList', // 批改页面
    path: '/planList',
    component: () => import('../pages/planList/index')
  },
  {
    name: 'homeWork', // 学员作业列表
    path: '/homeWork',
    component: () => import('../pages/homeWork/index')
  }
  // {
  //   name: 'correctionRemark', // 批改点评页
  //   path: '/correctionRemark',
  //   component: () => import('../pages/correctionRemark/index')
  // }
];

export const routes: RouteRecordRaw[] = (homeRouter as RouteRecordRaw[]).concat([
  {
    name: 'notFound',
    path: '/:pathMatch(.*)*',
    component: NotFound
  }
]);

export const router = createRouter({
  history: createWebHashHistory(),
  // history: createWebHashHistory(import.meta.env.BASE_URL), // es2019编译目标下import.env不支持
  routes,
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 };
  }
});

export default router;
